home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / FACTLN.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  528b  |  18 lines

  1. FUNCTION factln(n: integer): real;
  2. (* Programs using routine FACTLN must declare the array
  3. VAR
  4.    gla: ARRAY [1..100] OF real;
  5. and must initialize the array to the values
  6.    FOR i := 1 TO 100 DO gla[i] := -1.0;
  7. in the main routine. *)
  8. BEGIN
  9.    IF  (n < 0) THEN BEGIN
  10.       writeln ('pause in FACTLN - negative factorial'); readln END
  11.    ELSE IF (n <= 99) THEN BEGIN
  12.       IF  (gla[n+1] < 0.0) THEN  gla[n+1] := gammln(n+1.0);
  13.       factln := gla[n+1] END
  14.    ELSE BEGIN
  15.       factln := gammln(n+1.0)
  16.    END
  17. END;
  18.